# 哈希摘要算法
import hashlib, sys, hmac
from os import path

# 对文件内容做摘要算法, 计算hash
with open(path.join('.', 'py_modules', 'index.py'), 'r') as target_file:
    # 读取文件信息
    target_info = target_file.read()

    md5 = hashlib.md5()

    md5.update(target_info.encode('UTF-8'))

    file_hash = md5.hexdigest()

    print(file_hash[0:8])

# 哈希加密与加盐

# print('input password')

# # 初始化md5实例
# # md5 = hashlib.md5()
# # 加盐口令
# secret = 'bear_xiong'.encode('utf-8')
# # 获取用户输入
# pwd = sys.stdin.readline().strip('\n')

# md5_pwd = hmac.new(secret, pwd.encode('utf-8'), digestmod="MD5")
# # print(pwd)
# # md5.update(pwd.encode('utf-8'))

# # md5_pwd = md5.hexdigest()
# print(md5_pwd.hexdigest())